

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:huajianshe_app/common/load_image.dart';

class BgImageLayout extends StatelessWidget {

  final double imageHeight;
  final String imageUrl;
  final Color bgColor;
  final List<Widget> children;
  final SystemUiOverlayStyle overlayStyle;
  final Widget? floatingActionButton;
  final PreferredSizeWidget? appbar;

  const BgImageLayout({
    required this.imageHeight,
    required this.imageUrl,
    this.bgColor = Colors.transparent,
    this.overlayStyle = SystemUiOverlayStyle.light,
    required this.children,
    this.floatingActionButton,
    this.appbar
  });

  @override
  Widget build(BuildContext context) {
    Widget image = LoadImage(this.imageUrl, height: this.imageHeight, width: double.infinity,);
    return AnnotatedRegion<SystemUiOverlayStyle>(
      value: overlayStyle,
      child: Scaffold(
        appBar: appbar,
        backgroundColor: bgColor,
        floatingActionButton: floatingActionButton,
        body: Stack(children: [
          image,
          ... this.children
        ]),
      ),
    );
  }
}